package com.systemic.controller;

import com.systemic.core.ResponseResult;
import com.systemic.pojo.MindfulnessEvaluate;
import com.systemic.pojo.MindfulnessMedia;
import com.systemic.service.MindfulnessEvaluateService;
import com.systemic.vo.PageVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: EvaluateController
 * @Description:
 * @Author:
 * @CreateTime: 2024-02-02 09:21
 * @Version:
 **/
@RestController
@RequestMapping("/evaluate")
public class EvaluateController {

    @Resource
    private MindfulnessEvaluateService service;

    @PostMapping("/add")
    public ResponseResult<String> add(@RequestBody MindfulnessEvaluate mindfulnessEvaluate){
        int row = service.add(mindfulnessEvaluate);
        return row!=0 ? ResponseResult.success("新增成功") : ResponseResult.failed("新增失败");
    }

    @GetMapping("/delete/{id}")
    public ResponseResult<String> delete(@PathVariable("id")Integer id){
        int row = service.delete(id);
        return row!=0 ? ResponseResult.success("删除成功") : ResponseResult.failed("删除失败");
    }


    @PostMapping("/update")
    public ResponseResult<String> update(@RequestBody MindfulnessEvaluate mindfulnessEvaluate){
        int row = service.update(mindfulnessEvaluate);
        return row!=0 ? ResponseResult.success("修改成功") : ResponseResult.failed("修改失败");
    }


    @PostMapping("/select")
    public ResponseResult<List<MindfulnessEvaluate>> select(@RequestBody PageVo pageVo){
        List<MindfulnessEvaluate> res = service.selectByMid(pageVo);
        return !res.isEmpty() ? ResponseResult.success(res) : ResponseResult.failed("没有内容");
    }


}
